import request from '@/utils/request'

export function getBannerList() {
    return request({
        url: '/banner/all',
        method: 'GET'
    }).then(data => {
        return data.banners
    })
}

export function getBannerDetail(id) {
    return request({
        url: '/banner/' + id,
        method: 'GET'
    }).then(data => {
        return data.banner
    })
}

export function switchBannerStatus(id) {
    return request({
        url: '/banner/' + id + '/invisible',
        method: 'PUT'
    })
}

export function deleteBanner(id) {
    return request({
        url: '/banner/' + id,
        method: 'DELETE'
    })
}

export function getPostInfo(id) {
    return request({
        url: '/news/' + id + '/information',
        method: 'GET'
    }).then(data => {
        return data.newsInfo
    })
}

export function createBanner(data) {
    return request({
        url: '/banner',
        method: 'POST',
        data
    })
}

export function setBannerOrder(data) {
    return request({
        url: '/banner/order',
        method: 'PUT',
        data
    })
}

export function updateBanner(id, data) {
    return request({
        url: '/banner/' + id,
        method: 'PUT',
        data
    })
}
